<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags" %>
<%@ page import="com.fengke.csc.config.HostConfig" %>
<%
	HostConfig hostConfig = (HostConfig) request.getSession().getServletContext().getAttribute("hostConfig");
%>
<!DOCTYPE html>
	<!--[if lt IE 7 ]> <html lang="en" class="no-js ie6"> <![endif]-->
	<!--[if IE 7 ]>    <html lang="en" class="no-js ie7"> <![endif]-->
	<!--[if IE 8 ]>    <html lang="en" class="no-js ie8"> <![endif]-->
	<!--[if IE 9 ]>    <html lang="en" class="no-js ie9"> <![endif]-->
	<!--[if (gt IE 9)|!(IE)]><!--> <html lang="en" class="no-js"><!--<![endif]-->
<head>
	<title><%=hostConfig.getWebSiteName() %></title>
	<meta name="keywords" content="<%=hostConfig.getWebSiteName() %>" />
	<meta name="description" content="<%=hostConfig.getWebSiteName() %>" />
	<jsp:include page="../gadget/include_header.jsp"></jsp:include>
	<style>
		.tip_info {margin-left: 15px;}
		.col-sm-3 {width: 15%;}
		.col-sm-9 {width: 85%;}
		.btn.active {display: inline-block}
		.date-remove{cursor: pointer; background-color: rgb(251, 113, 66); border-radius: 100%; font-weight: normal; height: 17px; line-height: 15px; position: absolute; top: 6px; text-align: center; text-decoration: none; color: rgb(255, 255, 255); right: -20px; width: 17px; font-size: 11px;}
		a.date-remove:HOVER {text-decoration: none;color: #fff;}
	</style
</head>
<body>
	<!-- 头信息 Start -->
	<jsp:include page="../gadget/main_header.jsp"></jsp:include>
	<!-- 头信息 End -->
	<jsp:include page="../gadget/main_sidebar.jsp"></jsp:include>
	<div class="main-content">
		<div class="breadcrumbs" id="breadcrumbs">
			<ul class="breadcrumb">
				<li>
					<i class="icon-home home-icon"></i>
					<a href="#">首页</a>
				</li>
				<li class="active">商户管理</li>
			</ul><!-- .breadcrumb -->
		</div>
		<div class="page-content">
			<div class="page-header">
				<h1>
					<s:if test='"create".equals(#request.actionType)'>
						添加商户
					</s:if>
					<s:elseif test='"update".equals(#request.actionType)'>
						更新商户
					</s:elseif>
					<s:else>
						商户信息
					</s:else>
					<small>
						<i class="icon-double-angle-right"></i>
						 查看
					</small>
				</h1>
			</div><!-- /.page-header -->
			<div class="row">
				<div class="col-xs-12">
					<!-- PAGE CONTENT BEGINS -->

					<jsp:include page="../gadget/include_pageMessage.jsp"></jsp:include>
					
					<div class="row-fluid">
						<div class="span12">
							<div class="widget-box">
								<div class="widget-header widget-header-blue widget-header-flat">
									<h4 class="lighter">
										<s:if test='"create".equals(#request.actionType)'>
											新增
										</s:if>
										<s:elseif test='"update".equals(#request.actionType)'>
											更新
										</s:elseif>
										<s:else>
											查看
										</s:else>
									</h4>
								</div><!-- widget-header -->
								
								<div class="widget-body">
									<div class="widget-main">
										<div id="fuelux-wizard" class="row-fluid" data-target="#step-container">
											<ul class="wizard-steps">
												<li data-target="#step1" class="active">
													<span class="step">1</span>
													<span class="title">基本信息</span>
												</li>

												<li data-target="#step2">
													<span class="step">2</span>
													<span class="title">个人资料</span>
												</li>
												
												<li data-target="#step3">
													<span class="step">3</span>
													<span class="title">确认提交</span>
												</li>
											</ul>
										</div><!-- end fuelux-wizard -->
										<div class="step-content row-fluid position-relative" id="step-container">
										<form class="form-horizontal" id="csc_agentProfile_edit_form" enctype="multipart/form-data" method="post">
											<s:if test='"update".equals(#request.actionType)'>
												<input type="hidden" name="agentProfileVO.adminModel.id" value="<s:property value="agentProfileVO.adminModel.id" />" />
											</s:if>
											<div class="step-pane active" id="step1">
												<h3 class="lighter block green">Enter the following information</h3>
													
												<div class="form-group">
													<label class="control-label col-xs-12 col-sm-3 no-padding-right" for="admin_username"><span style="color: red;">*</span>用户名：</label>

													<div class="col-xs-12 col-sm-9">
														<div class="clearfix">
															<input type="text" name="agentProfileVO.adminModel.username" id="admin_username" maxlength="20" class="col-xs-12 col-sm-6" />
														</div>
													</div>
												</div>
												<div class="space-2"></div>
												
												<div class="form-group">
													<label class="control-label col-xs-12 col-sm-3 no-padding-right" for="admin_password"><span style="color: red;">*</span>密码：</label>

													<div class="col-xs-12 col-sm-9">
														<div class="clearfix">
															<input type="password" name="agentProfileVO.adminModel.password" id="admin_password" maxlength="20" class="col-xs-12 col-sm-6" />
														</div>
													</div>
												</div>
												<div class="space-2"></div>
												<div class="form-group">
													<label class="control-label col-xs-12 col-sm-3 no-padding-right" for="admin_repassword"><span style="color: red;">*</span>确认密码：</label>

													<div class="col-xs-12 col-sm-9">
														<div class="clearfix">
															<input type="password" name="repassword" id="admin_repassword" maxlength="20" class="col-xs-12 col-sm-6" />
														</div>
													</div>
												</div>
												<div class="space-2"></div>
												<div class="form-group">
													<label class="control-label col-xs-12 col-sm-3 no-padding-right" for="admin_email"><span style="color: red;">*</span>E-mail：</label>

													<div class="col-xs-12 col-sm-9">
														<div class="clearfix">
															<input type="text" name="agentProfileVO.adminModel.email" id="admin_email" maxlength="200" class="col-xs-12 col-sm-6" />
														</div>
													</div>
												</div>
												<div class="space-2"></div>
												<div class="form-group">
													<label class="control-label col-xs-12 col-sm-3 no-padding-right" for="admin_phoneNum"><span style="color: red;">*</span>联系电话：</label>

													<div class="col-xs-12 col-sm-9">
														<div class="clearfix">
															<input type="text" name="agentProfileVO.adminModel.phoneNum" id="admin_phoneNum" maxlength="20" class="col-xs-12 col-sm-6" />
														</div>
													</div>
												</div>
												<div class="space-2"></div>
												<div class="form-group">
													<label class="control-label col-xs-12 col-sm-3 no-padding-right" for="admin_roles"><span style="color: red;">*</span>角色：</label>

													<div class="col-xs-12 col-sm-9">
														<div class="clearfix">
															<s:if test="roleVOList != null && roleVOList.size() > 0">
																<s:iterator value="roleVOList" var="roleVO" status="countIdx">
																	<label title='<s:property value="#roleVO.roleModel.description" />' style="margin-right: 5px;">
																		<input id="role_check_<s:property value='#roleVO.roleModel.id' />" name="agentProfileVO.agentRoles" value="<s:property value='#roleVO.roleModel.id' />" type="checkbox" class="ace" />
																		<span class="lbl">&nbsp;<s:property value="#roleVO.roleModel.name" /></span>
																	</label>
																</s:iterator>
															</s:if>
<!-- 															<input type="text" name="agentProfileVO.roles" id="admin_roles" class="col-xs-12 col-sm-6" /> -->
														</div>
													</div>
												</div>
												<s:if test="#session.AgentProfile.isMerchant()">
												<div class="space-2" style="display: none;"></div>
												<div class="form-group" style="display: none;">
												</s:if>
												<s:else>
												<div class="space-2"></div>
												<div class="form-group">
												</s:else>
													<label class="control-label col-xs-12 col-sm-3 no-padding-right" for="admin_setting">设置：</label>

													<div class="col-xs-12 col-sm-9">
														<div class="clearfix">
															<label>
																<input type="hidden" id="admin_isEnabled" name="agentProfileVO.adminModel.isEnabled" value="" />
																<input type="hidden" id="admin_canSetMarketable" name="agentProfileVO.adminModel.canSetMarketable" value="" />
																<input type="hidden" id="admin_isLocked" name="agentProfileVO.adminModel.isLocked" value="" />
																<input id="admin_isEnabled_box" class="ace ace-switch ace-switch-5" type="checkbox" />
																<span class="lbl">&nbsp;是否启用</span>
															</label>
															<label>
																<input id="admin_canSetMarketable_box" class="ace ace-switch ace-switch-5" type="checkbox" />
																<span class="lbl">&nbsp;是否可设置上架</span>
															</label>
															<label>
																<input id="admin_isLocked_box" class="ace ace-switch ace-switch-5" type="checkbox" />
																<span class="lbl">&nbsp;是否锁定</span>
															</label>
														</div>
													</div>
												</div>
												<div class="space-2"></div>
												<div class="form-group">
													<label class="control-label col-xs-12 col-sm-3 no-padding-right" for="admin_company"><span style="color: red;">*</span>申请单位：</label>

													<div class="col-xs-12 col-sm-9">
														<div class="clearfix">
															<input type="text" name="agentProfileVO.adminModel.company" id="admin_company" maxlength="200" class="col-xs-12 col-sm-6" />
														</div>
													</div>
												</div>
												<div class="space-2"></div>
												<div class="form-group">
													<label class="control-label col-xs-12 col-sm-3 no-padding-right" for="admin_paperNum"><span style="color: red;">*</span>证件号：</label>

													<div class="col-xs-12 col-sm-9">
														<div class="clearfix">
															<input type="text" name="agentProfileVO.adminModel.paperNum" id="admin_paperNum" maxlength="200" class="col-xs-12 col-sm-6" />
														</div>
													</div>
												</div>
												<div class="space-2"></div>
												<div class="form-group">
													<label class="control-label col-xs-12 col-sm-3 no-padding-right" for="admin_adminStory"><span style="color: red;">*</span>商家故事：</label>

													<div class="col-xs-12 col-sm-9">
														<textarea name="agentProfileVO.adminModel.adminStory" id="admin_adminStory" style="display: none;" rows="1" cols="1"></textarea>
														<div class="clearfix" style="border: 1px solid #d5d5d5;">
															<div id="admin_adminStory_div" class="wysiwyg-editor"></div>
														</div>
													</div>
												</div>
											</div><!-- end step1 -->
											
											<div class="step-pane" id="step2">
												<h3 class="lighter block green">Enter the following information</h3>
												<div class="form-group">
													<label class="control-label col-xs-12 col-sm-3 no-padding-right" for="admin_department"><span style="color: red;">*</span>部门：</label>

													<div class="col-xs-12 col-sm-9">
														<div class="clearfix">
															<input type="text" name="agentProfileVO.adminModel.department" id="admin_department" maxlength="200" class="col-xs-12 col-sm-6" />
														</div>
													</div>
												</div>
												<div class="space-2"></div>
												<div class="form-group">
													<label class="control-label col-xs-12 col-sm-3 no-padding-right" for="admin_name"><span style="color: red;">*</span>姓名：</label>

													<div class="col-xs-12 col-sm-9">
														<div class="clearfix">
															<input type="text" name="agentProfileVO.adminModel.name" id="admin_name" maxlength="200" class="col-xs-12 col-sm-6" />
														</div>
													</div>
												</div>
												<div class="space-2"></div>
												<div class="form-group">
													<label class="control-label col-xs-12 col-sm-3 no-padding-right" for="admin_address"><span style="color: red;">*</span>地址：</label>

													<div class="col-xs-12 col-sm-9">
														<div class="clearfix">
															<input type="text" name="agentProfileVO.adminModel.address" id="admin_address" maxlength="200" class="col-xs-12 col-sm-6" />
														</div>
													</div>
												</div>
												<div class="space-2"></div>
												<div class="form-group">
													<label class="control-label col-xs-12 col-sm-3 no-padding-right" for="admin_idNum"><span style="color: red;">*</span>身份证号：</label>

													<div class="col-xs-12 col-sm-9">
														<div class="clearfix">
															<input type="text" name="agentProfileVO.adminModel.idNum" id="admin_idNum" maxlength="18" class="col-xs-12 col-sm-6" />
														</div>
													</div>
												</div>
												<div class="space-2"></div>
												<div class="form-group">
													<label class="control-label col-xs-12 col-sm-3 no-padding-right" for="admin_idHandsImg"><s:if test='"create".equals(#request.actionType)'><span style="color: red;">*</span></s:if>手持身份证照片：</label>

													<div class="col-xs-12 col-sm-9">
														<div class="clearfix" style="width: 50%;">
															<input type="file" name="agentProfileVO.idHandsImg.file" id="admin_idHandsImg" />
														</div>
													</div>
												</div>
												<div class="space-2"></div>
												<div class="form-group">
													<label class="control-label col-xs-12 col-sm-3 no-padding-right" for="admin_idFrontImg"><s:if test='"create".equals(#request.actionType)'><span style="color: red;">*</span></s:if>身份证正面照片：</label>

													<div class="col-xs-12 col-sm-9">
														<div class="clearfix" style="width: 50%;">
															<input type="file" name="agentProfileVO.idFrontImg.file" id="admin_idFrontImg" />
														</div>
													</div>
												</div>
												<div class="space-2"></div>
												<div class="form-group">
													<label class="control-label col-xs-12 col-sm-3 no-padding-right" for="admin_idBackImg"><s:if test='"create".equals(#request.actionType)'><span style="color: red;">*</span></s:if>身份证背面照片：</label>

													<div class="col-xs-12 col-sm-9">
														<div class="clearfix" style="width: 50%;">
															<input type="file" name="agentProfileVO.idBackImg.file" id="admin_idBackImg" />
														</div>
													</div>
												</div>
												
											</div><!-- end step2 -->
											
											<div class="step-pane" id="step3">
												<div class="center">
													<h3 class="green">Congrats!</h3>
													Your Admin account is ready to ship! Click finish to continue!
												</div>
											</div>
										</form><!-- end edit form -->
										</div><!--  end step-content -->
										
										<hr />
										<div class="row-fluid wizard-actions">
											<button type="button" class="btn btn-prev">
												<i class="icon-arrow-left"></i>
												上一步
											</button>

											<button type="button" class="btn btn-success btn-next" data-last="输入完成，确认提交 ">
												下一步
												<i class="icon-arrow-right icon-on-right"></i>
											</button>
										</div>
									</div><!-- end class="widget-main" -->
								</div><!-- widget-body -->
							</div><!-- end class="widget-box" -->
						</div><!-- end class="span12" -->
					</div><!-- end class="row-fluid" -->
				</div>
			</div>
		</div>
	</div>
	<s:if test='"update".equals(#request.actionType)'>
	<div style="display: none;">
		<div id="update_admin_adminStory_div"><s:property value="agentProfileVO.adminModel.adminStory" escapeHtml="false" /></div>
	</div>
	</s:if>
<jsp:include page="../gadget/include_script.jsp"></jsp:include>
<script type="text/javascript">
jQuery(function($) {
	$('#sidebar_agentProfile').addClass('open');
	$('#sidebar_agentProfile').addClass('active');
	$('#sidebar_agentProfile_manager').addClass('active');
	
	init_ace_file_input('#admin_idHandsImg, #admin_idFrontImg, #admin_idBackImg');
	
	init_ace_wysiwyg('#admin_adminStory_div');
	
	$('#admin_isEnabled_box').removeAttr('checked').on('click', function(){
		$('#admin_isEnabled').attr('value', this.checked);
	});
	$('#admin_canSetMarketable_box').removeAttr('checked').on('click', function(){
		$('#admin_canSetMarketable').attr('value', this.checked);
	});
	$('#admin_isLocked_box').removeAttr('checked').on('click', function(){
		$('#admin_isLocked').attr('value', this.checked);
	});
	
	function validAdminStory() {
		var html = $('#admin_adminStory_div').html();
		if($.trim(html) == '') {
			$('#admin_adminStory').closest('.form-group').removeClass('has-info').addClass('has-error');
			return false;
		} else {
			$('#admin_adminStory').closest('.form-group').removeClass('has-error').addClass('has-info');
			return true;
		}
	}
	
	var $validation = true;
	$('#fuelux-wizard').ace_wizard().on('change' , function(e, info){
		if((info.step == 1 || info.step == 2) && $validation) {
			// step 1 // step 2
			var formValidResult = $('#csc_agentProfile_edit_form').valid();
			//alert(formValidResult);
			return formValidResult && validAdminStory();
		}
	}).on('finished', function(e) {
		//$('#csc_product_search_form').submit();
		// 处理Step1富文本编辑器
		//$('#product_introduction').text($('#product_introduction_div').html());
		$('#admin_adminStory').text($('#admin_adminStory_div').html());
		
		// 提交表单
		$('#csc_agentProfile_edit_form').submit();
		/**
		bootbox.dialog({
			message: "Thank you! Your information was successfully saved!", 
			buttons: {
				"success" : {
					"label" : "OK",
					"className" : "btn-sm btn-primary"
				}
			}
		});
		**/
	}).on('stepclick', function(e){
		alert(e);
		//return false;//prevent clicking on steps
	});
	
	$('#csc_agentProfile_edit_form').validate({
		errorElement: 'div',
		errorClass: 'help-block',
		focusInvalid: false,
		rules: {
			"agentProfileVO.adminModel.username" : {
				required: true,
				pattern: /^[0-9a-z_A-Z\u4e00-\u9fa5]+$/,
				minlength: 2,
				maxlength: 20,
				remote: {
					url: "agentProfile/agentProfileValidator.action?agentProfileId=<s:property value='agentProfileVO.adminModel.id' />",
					cache: false,
					type : "post",
					dataType : "json",
					data : {
						property : "username",
						propertyValue : function() {
							return $("#admin_username").val();
						}
					}
				}
			},
			"agentProfileVO.adminModel.password" : {
				required: true,
				pattern: /^[^\s&\"<>]+$/,
				minlength: 4,
				maxlength: 20,
			},
			"repassword" : {
				required: true,
				equalTo: "#admin_password",
			},
			"agentProfileVO.adminModel.email" : {
				required: true,
				email: true,
			},
			"agentProfileVO.adminModel.phoneNum" : {
				required: true,
				pattern: /^((1[3-9]{1}[0-9]{1}\d{8})|((0\d{2,3}-)?\d{7,8})|(1[3,5,8,7]{1}[\d]{9})|(((400)-(\d{3})-(\d{4}))|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{3,7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$))$/,
			},
			"agentProfileVO.agentRoles" : {
				required: true,
			},
			"agentProfileVO.adminModel.company" : {
				required: true,
			},
			"agentProfileVO.adminModel.paperNum" : {
				required: true,
			},
			"agentProfileVO.adminModel.department" : {
				required: true,
			},
			"agentProfileVO.adminModel.name" : {
				required: true,
			},
			"agentProfileVO.adminModel.address" : {
				required: true,
			},
			"agentProfileVO.adminModel.idNum" : {
				required: true,
				pattern: /^(\d{15}$|^\d{18}$|^\d{17}(\d|X|x))$/,
			},
			"agentProfileVO.idHandsImg.file" : {
				<s:if test='"create".equals(#request.actionType)'>
				required: true,
				</s:if>
				fileExtName : "jpg,gif,png",
				validateFileSize : 2000000,
			},
			"agentProfileVO.idFrontImg.file" : {
				<s:if test='"create".equals(#request.actionType)'>
				required: true,
				</s:if>
				fileExtName : "jpg,gif,png",
				validateFileSize : 2000000,
			},
			"agentProfileVO.idBackImg.file" : {
				<s:if test='"create".equals(#request.actionType)'>
				required: true,
				</s:if>
				fileExtName : "jpg,gif,png",
				validateFileSize : 2000000,
			}
		},
		messages: {
			"agentProfileVO.adminModel.username" : {
				required: "不能为空",
				pattern: "非法字符",
				minlength: "长度不允许小于2",
				maxlength: "长度不允许大于20",
				remote: "用户名已存在！",
			},
			"agentProfileVO.adminModel.password" : {
				required: "不能为空",
				pattern: "非法字符",
				minlength: "长度不允许小于4",
				maxlength: "长度不允许大于20",
			},
			"repassword" : {
				required: "请输入确认密码",
				equalTo: "同密码不一致",
			},
			"agentProfileVO.adminModel.email" : {
				required: "不能为空",
				email: "E-mail格式错误",
			},
			"agentProfileVO.adminModel.phoneNum" : {
				required: "不能为空",
				pattern: "格式错误",
			},
			"agentProfileVO.agentRoles" : {
				required: "请选择权限",
			},
			"agentProfileVO.adminModel.company" : {
				required: "不能为空",
			},
			"agentProfileVO.adminModel.paperNum" : {
				required: "不能为空",
			},
			"agentProfileVO.adminModel.department" : {
				required: "不能为空",
			},
			"agentProfileVO.adminModel.name" : {
				required: "不能为空",
			},
			"agentProfileVO.adminModel.address" : {
				required: "不能为空",
			},
			"agentProfileVO.adminModel.idNum" : {
				required: "不能为空",
				pattern: "格式错误",
			},
			"agentProfileVO.idHandsImg.file" : {
				checkProductImages: "请上传产品轮播图",
				fileExtName: "请上传jpg,gif,png文件",
				validateFileSize : "文件大小不能超过2M",
			},
			"agentProfileVO.idFrontImg.file" : {
				checkProductImages: "请上传产品轮播图",
				fileExtName: "请上传jpg,gif,png文件",
				validateFileSize : "文件大小不能超过2M",
			},
			"agentProfileVO.idBackImg.file" : {
				checkProductImages: "请上传产品轮播图",
				fileExtName: "请上传jpg,gif,png文件",
				validateFileSize: "文件大小不能超过2M",
			}
		},
		
		invalidHandler: function (event, validator) { //display error alert on form submit   
			$('.alert-danger', $('.login-form')).show();
		},

		highlight: function (e) {
			$(e).closest('.form-group').removeClass('has-info').addClass('has-error');
		},

		success: function (e) {
			$(e).closest('.form-group').removeClass('has-error').addClass('has-info');
			$(e).remove();
		},

		errorPlacement: function (error, element) {
			if(element.is(':checkbox') || element.is(':radio')) {
				var controls = element.closest('div[class*="col-"]');
				if(controls.find(':checkbox,:radio').length > 1) controls.append(error);
				else error.insertAfter(element.nextAll('.lbl:eq(0)').eq(0));
			}
			else if(element.is('.select2')) {
				error.insertAfter(element.siblings('[class*="select2-container"]:eq(0)'));
			}
			else if(element.is('.chosen-select')) {
				error.insertAfter(element.siblings('[class*="chosen-container"]:eq(0)'));
			}
			else error.insertAfter(element.parent());
		}//,

		//submitHandler: function (form) {
			//$(form).submit();
		//},
		//invalidHandler: function (form) {
		//}
	});
});
function init_ace_file_input(filterString) {
	$(filterString).ace_file_input({
		no_file:'No File ...',
		btn_choose:'Choose',
		btn_change:'Change',
		droppable:false,
		onchange:null,
		thumbnail:false //| true | large
		//whitelist:'gif|png|jpg|jpeg',
		//blacklist:'exe|php'
		//onchange:''
		//
	});
}
function init_ace_wysiwyg(filterString) {
	$(filterString).ace_wysiwyg({
		toolbar:
			[
				'font',
				null,
				'fontSize',
				null,
				{name:'bold', className:'btn-info'},
				{name:'italic', className:'btn-info'},
				{name:'strikethrough', className:'btn-info'},
				{name:'underline', className:'btn-info'},
				null,
				{name:'insertunorderedlist', className:'btn-success'},
				{name:'insertorderedlist', className:'btn-success'},
				{name:'outdent', className:'btn-purple'},
				{name:'indent', className:'btn-purple'},
				null,
				{name:'justifyleft', className:'btn-primary'},
				{name:'justifycenter', className:'btn-primary'},
				{name:'justifyright', className:'btn-primary'},
				{name:'justifyfull', className:'btn-inverse'},
				null,
				{name:'createLink', className:'btn-pink'},
				{name:'unlink', className:'btn-pink'},
				null,
				{name:'insertImage', className:'btn-success'},
				null,
				'foreColor',
				null,
				{name:'undo', className:'btn-grey'},
				{name:'redo', className:'btn-grey'}
			],
			'wysiwyg': {
				fileUploadError: showErrorAlert
			}
		}).prev().addClass('wysiwyg-style2');
}
function showErrorAlert (reason, detail) {
	var msg='';
	if (reason==='unsupported-file-type') { msg = "Unsupported format " +detail; }
	else {
		console.log("error uploading file", reason, detail);
	}
	$('<div class="alert"> <button type="button" class="close" data-dismiss="alert">&times;</button>'+ 
	 '<strong>File upload error</strong> '+msg+' </div>').prependTo('#alerts');
}
</script>
<s:if test='"create".equals(#request.actionType)'>
	<script type="text/javascript">
	jQuery(function($) {
		$('#csc_agentProfile_edit_form').attr('action', 'agentProfile/createAgentProfile.action');
	});
	</script>
</s:if>
<s:elseif test='"update".equals(#request.actionType)'>
	<script type="text/javascript">
	jQuery(function($) {
		$('#csc_agentProfile_edit_form').attr('action', 'agentProfile/updateAgentProfile.action');
		$('#admin_username').attr('value', '<s:property value="agentProfileVO.adminModel.username" />');
		$('#admin_email').attr('value', '<s:property value="agentProfileVO.adminModel.email" />');
		$('#admin_phoneNum').attr('value', '<s:property value="agentProfileVO.adminModel.phoneNum" />');
		$('#admin_company').attr('value', '<s:property value="agentProfileVO.adminModel.company" />');
		$('#admin_paperNum').attr('value', '<s:property value="agentProfileVO.adminModel.paperNum" />');
		$('#admin_department').attr('value', '<s:property value="agentProfileVO.adminModel.department" />');
		$('#admin_name').attr('value', '<s:property value="agentProfileVO.adminModel.name" />');
		$('#admin_address').attr('value', '<s:property value="agentProfileVO.adminModel.address" />');
		$('#admin_idNum').attr('value', '<s:property value="agentProfileVO.adminModel.idNum" />');
		
		$('#product_isEnabled').attr('value', '<s:property value="agentProfileVO.adminModel.isEnabled" />');
		var isEnabled = '<s:property value="agentProfileVO.adminModel.isEnabled" />';
		if(isEnabled != null && isEnabled == 'true') {
			$('#admin_isEnabled_box').click();
		}
		$('#admin_canSetMarketable').attr('value', '<s:property value="agentProfileVO.adminModel.canSetMarketable" />');
		var canSetMarketable = '<s:property value="agentProfileVO.adminModel.canSetMarketable" />';
		if(canSetMarketable != null && canSetMarketable == 'true') {
			$('#admin_canSetMarketable_box').click();
		}
		$('#product_isLocked').attr('value', '<s:property value="agentProfileVO.adminModel.isLocked" />');
		var isLocked = '<s:property value="agentProfileVO.adminModel.isLocked" />';
		if(isLocked != null && isLocked == 'true') {
			$('#admin_isLocked_box').click();
		}
		
		$('#admin_adminStory_div').html($('#update_admin_adminStory_div').html());
	});
	</script>
	<s:if test="agentProfileVO.adminRoleModelList != null && agentProfileVO.adminRoleModelList.size() > 0">
		<s:iterator value="agentProfileVO.adminRoleModelList" var="adminRoleModel">
			<script type="text/javascript">
				jQuery(function($) {
					$('#role_check_<s:property value="#adminRoleModel.roleModel.id" />').attr('checked', 'checked');
				});
			</script>
		</s:iterator>
	</s:if>
</s:elseif>
</body>
</html>